<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        button {
            color: red;
        }
    </style>
</head>

<body>
    <input type="text" placeholder="请输入收到的验证码" /><button>获取验证码</button>

    <script>
        let btn = $("button")[0];
        let text_input = $("input")[0];
        btn.onclick = function() {

            btn.disabled = "disabled";
            btn.style.color = "#666";
            let num = 10;
            var timer = setInterval(function() {
                num--;

                btn.innerHTML = "重新获取（" + num + "s)";
                if (num == 0) {
                    clearInterval(timer);
                    btn.innerHTML = "获取验证码";
                    btn.style.color = "red";
                    btn.disabled = "";
                }
            }, 1000)
        }

        function $(select) {
            return document.querySelectorAll(select);
        }
    </script>
</body>

</html>